package Threading2;

// 第二种创建线程的方法：实现Thread类的接口：Runnable 重写 run 方法

class MyRunnable implements java.lang.Runnable {
    @Override
    public void run() {
        while (true) {
            System.out.println("hello tt1");
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}

public class ThreadingDemo2 {
    public static void main(String[] args) {
        MyRunnable myRunnable = new MyRunnable();
        Thread t = new Thread(myRunnable);
        t.start();

        while (true) {
            System.out.println("hello world");
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
